home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Tool Chest / !Interfaces / Universal Interfaces 2.0a1 / CIncludes / ADSP.h next >
Encoding:
C/C++ Source or Header  |  1994-07-17  |  10.1 KB  |  276 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        ADSP.h
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a1.  ETO #15, MPW prerelease.  Sunday, July 17, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. */
  16.  
  17. #ifndef __ADSP__
  18. #define __ADSP__
  19.  
  20.  
  21. #ifndef __ERRORS__
  22. #include <Errors.h>
  23. #endif
  24. /*    #include <ConditionalMacros.h>                                */
  25.  
  26. #ifndef __APPLETALK__
  27. #include <AppleTalk.h>
  28. #endif
  29. /*    #include <Types.h>                                            */
  30. /*    #include <OSUtils.h>                                        */
  31. /*        #include <MixedMode.h>                                    */
  32.  
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36.  
  37. #if GENERATINGPOWERPC
  38. #pragma options align=mac68k
  39. #endif
  40.  
  41. #ifdef __CFM68K__
  42. #pragma lib_export on
  43. #endif
  44.  
  45.  
  46. enum {
  47.     dspInit                        = 255,                            /* create a new connection end */
  48.     dspRemove                    = 254,                            /* remove a connection end */
  49.     dspOpen                        = 253,                            /* open a connection */
  50.     dspClose                    = 252,                            /* close a connection */
  51.     dspCLInit                    = 251,                            /* create a connection listener */
  52.     dspCLRemove                    = 250,                            /* remove a connection listener */
  53.     dspCLListen                    = 249,                            /* post a listener request */
  54.     dspCLDeny                    = 248,                            /* deny an open connection request */
  55.     dspStatus                    = 247,                            /* get status of connection end */
  56.     dspRead                        = 246,                            /* read data from the connection */
  57.     dspWrite                    = 245,                            /* write data on the connection */
  58.     dspAttention                = 244                            /* send an attention message */
  59. };
  60.  
  61. enum {
  62.     dspOptions                    = 243,                            /* set connection end options */
  63.     dspReset                    = 242,                            /* forward reset the connection */
  64.     dspNewCID                    = 241,                            /* generate a cid for a connection end */
  65. /* connection opening modes */
  66.     ocRequest                    = 1,                            /* request a connection with remote */
  67.     ocPassive                    = 2,                            /* wait for a connection request from remote */
  68.     ocAccept                    = 3,                            /* accept request as delivered by listener */
  69.     ocEstablish                    = 4,                            /* consider connection to be open */
  70. /* connection end states */
  71.     sListening                    = 1,                            /* for connection listeners */
  72.     sPassive                    = 2,                            /* waiting for a connection request from remote */
  73.     sOpening                    = 3,                            /* requesting a connection with remote */
  74.     sOpen                        = 4,                            /* connection is open */
  75.     sClosing                    = 5,                            /* connection is being torn down */
  76.     sClosed                        = 6,                            /* connection end state is closed */
  77. /* client event flags */
  78.     eClosed                        = 0x80,                            /* received connection closed advice */
  79.     eTearDown                    = 0x40,                            /* connection closed due to broken connection */
  80.     eAttention                    = 0x20,                            /* received attention message */
  81.     eFwdReset                    = 0x10,                            /* received forward reset advice */
  82. /* miscellaneous constants */
  83.     attnBufSize                    = 570,                            /* size of client attention buffer */
  84.     minDSPQueueSize                = 100                            /* Minimum size of receive or send Queue */
  85. };
  86.  
  87. /* connection control block */
  88. struct TRCCB {
  89.     struct TRCCB                    *ccbLink;                    /* link to next ccb */
  90.     UInt16                            refNum;                        /* user reference number */
  91.     UInt16                            state;                        /* state of the connection end */
  92.     UInt8                            userFlags;                    /* flags for unsolicited connection events */
  93.     UInt8                            localSocket;                /* socket number of this connection end */
  94.     AddrBlock                        remoteAddress;                /* internet address of remote end */
  95.     UInt16                            attnCode;                    /* attention code received */
  96.     UInt16                            attnSize;                    /* size of received attention data */
  97.     void                            *attnPtr;                    /* ptr to received attention data */
  98.     UInt8                            reserved[220];                /* for adsp internal use */
  99. };
  100. typedef struct TRCCB TRCCB;
  101.  
  102. typedef TRCCB *TPCCB;
  103.  
  104. typedef struct DSPParamBlock DSPParamBlock, *DSPPBPtr;
  105.  
  106. /*
  107.         ADSPConnectionEventProcPtr uses register based parameters on the 68k and cannot
  108.         be written in or called from a high-level language without the help of
  109.         mixed mode or assembly glue.
  110.  
  111.         In:
  112.          => sourceCCB       A1.L
  113. */
  114. /*
  115.         ADSPCompletionProcPtr uses register based parameters on the 68k and cannot
  116.         be written in or called from a high-level language without the help of
  117.         mixed mode or assembly glue.
  118.  
  119.         In:
  120.          => thePBPtr        A0.L
  121. */
  122.  
  123. #if GENERATINGCFM
  124. typedef UniversalProcPtr ADSPConnectionEventUPP;
  125. typedef UniversalProcPtr ADSPCompletionUPP;
  126. #else
  127. typedef Register68kProcPtr ADSPConnectionEventUPP;
  128. typedef Register68kProcPtr ADSPCompletionUPP;
  129. #endif
  130.  
  131. struct TRinitParams {
  132.     TPCCB                            ccbPtr;                        /* pointer to connection control block */
  133.     ADSPConnectionEventUPP            userRoutine;                /* client routine to call on event */
  134.     UInt16                            sendQSize;                    /* size of send queue (0..64K bytes) */
  135.     void                            *sendQueue;                    /* client passed send queue buffer */
  136.     UInt16                            recvQSize;                    /* size of receive queue (0..64K bytes) */
  137.     void                            *recvQueue;                    /* client passed receive queue buffer */
  138.     void                            *attnPtr;                    /* client passed receive attention buffer */
  139.     UInt8                            localSocket;                /* local socket number */
  140.     UInt8                            filler1;                    /* filler for proper byte alignment */
  141. };
  142. typedef struct TRinitParams TRinitParams, *TRinitParamsPtr;
  143.  
  144. struct TRopenParams {
  145.     UInt16                            localCID;                    /* local connection id */
  146.     UInt16                            remoteCID;                    /* remote connection id */
  147.     AddrBlock                        remoteAddress;                /* address of remote end */
  148.     AddrBlock                        filterAddress;                /* address filter */
  149.     UInt32                            sendSeq;                    /* local send sequence number */
  150.     UInt16                            sendWindow;                    /* send window size */
  151.     UInt32                            recvSeq;                    /* receive sequence number */
  152.     UInt32                            attnSendSeq;                /* attention send sequence number */
  153.     UInt32                            attnRecvSeq;                /* attention receive sequence number */
  154.     UInt8                            ocMode;                        /* open connection mode */
  155.     UInt8                            ocInterval;                    /* open connection request retry interval */
  156.     UInt8                            ocMaximum;                    /* open connection request retry maximum */
  157.     UInt8                            filler2;                    /* filler for proper byte alignment */
  158. };
  159. typedef struct TRopenParams TRopenParams, *TRopenParamsPtr;
  160.  
  161. struct TRcloseParams {
  162.     UInt8                            abort;                        /* abort connection immediately if non-zero */
  163.     UInt8                            filler3;                    /* filler for proper byte alignment */
  164. };
  165. typedef struct TRcloseParams TRcloseParams, *TRcloseParamsPtr;
  166.  
  167. struct TRioParams {
  168.     UInt16                            reqCount;                    /* requested number of bytes */
  169.     UInt16                            actCount;                    /* actual number of bytes */
  170.     void                            *dataPtr;                    /* pointer to data buffer */
  171.     UInt8                            eom;                        /* indicates logical end of message */
  172.     UInt8                            flush;                        /* send data now */
  173. };
  174. typedef struct TRioParams TRioParams, *TRioParamsPtr;
  175.  
  176. struct TRattnParams {
  177.     UInt16                            attnCode;                    /* client attention code */
  178.     UInt16                            attnSize;                    /* size of attention data */
  179.     void                            *attnData;                    /* pointer to attention data */
  180.     UInt8                            attnInterval;                /* retransmit timer in 10-tick intervals */
  181.     UInt8                            filler4;                    /* filler for proper byte alignment */
  182. };
  183. typedef struct TRattnParams TRattnParams, *TRattnParamsPtr;
  184.  
  185. struct TRstatusParams {
  186.     TPCCB                            statusCCB;                    /* pointer to ccb */
  187.     UInt16                            sendQPending;                /* pending bytes in send queue */
  188.     UInt16                            sendQFree;                    /* available buffer space in send queue */
  189.     UInt16                            recvQPending;                /* pending bytes in receive queue */
  190.     UInt16                            recvQFree;                    /* available buffer space in receive queue */
  191. };
  192. typedef struct TRstatusParams TRstatusParams, *TRstatusParamsPtr;
  193.  
  194. struct TRoptionParams {
  195.     UInt16                            sendBlocking;                /* quantum for data packets */
  196.     UInt8                            sendTimer;                    /* send timer in 10-tick intervals */
  197.     UInt8                            rtmtTimer;                    /* retransmit timer in 10-tick intervals */
  198.     UInt8                            badSeqMax;                    /* threshold for sending retransmit advice */
  199.     UInt8                            useCheckSum;                /* use ddp packet checksum */
  200. };
  201. typedef struct TRoptionParams TRoptionParams, *TRoptionParamsPtr;
  202.  
  203. struct TRnewcidParams {
  204.     UInt16                            newcid;                        /* new connection id returned */
  205. };
  206. typedef struct TRnewcidParams TRnewcidParams, *TRnewcidParamsPtr;
  207.  
  208. struct DSPParamBlock {
  209.     struct QElem                    *qLink;
  210.     short                            qType;
  211.     short                            ioTrap;
  212.     Ptr                                ioCmdAddr;
  213.     ADSPCompletionUPP                ioCompletion;
  214.     OSErr                            ioResult;
  215.     StringPtr                        ioNamePtr;
  216.     short                            ioVRefNum;
  217.     short                            ioCRefNum;                    /* adsp driver refNum */
  218.     short                            csCode;                        /* adsp driver control code */
  219.     long                            qStatus;                    /* adsp internal use */
  220.     short                            ccbRefNum;
  221.     union {
  222.         TRinitParams                    initParams;                /*dspInit, dspCLInit*/
  223.         TRopenParams                    openParams;                /*dspOpen, dspCLListen, dspCLDeny*/
  224.         TRcloseParams                    closeParams;            /*dspClose, dspRemove*/
  225.         TRioParams                        ioParams;                /*dspRead, dspWrite*/
  226.         TRattnParams                    attnParams;                /*dspAttention*/
  227.         TRstatusParams                    statusParams;            /*dspStatus*/
  228.         TRoptionParams                    optionParams;            /*dspOptions*/
  229.         TRnewcidParams                    newCIDParams;            /*dspNewCID*/
  230.     } u;
  231. };
  232.  
  233. enum {
  234.     uppADSPConnectionEventProcInfo = kRegisterBased
  235.          | REGISTER_ROUTINE_PARAMETER(1, kRegisterA1, SIZE_CODE(sizeof(TPCCB))),
  236.     uppADSPCompletionProcInfo = kRegisterBased
  237.          | REGISTER_ROUTINE_PARAMETER(1, kRegisterA0, SIZE_CODE(sizeof(DSPPBPtr)))
  238. };
  239.  
  240. #if GENERATINGCFM
  241. #define NewADSPConnectionEventProc(userRoutine)        \
  242.         (ADSPConnectionEventUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppADSPConnectionEventProcInfo, GetCurrentArchitecture())
  243. #define NewADSPCompletionProc(userRoutine)        \
  244.         (ADSPCompletionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppADSPCompletionProcInfo, GetCurrentArchitecture())
  245. #else
  246. #define NewADSPConnectionEventProc(userRoutine)        \
  247.         ((ADSPConnectionEventUPP) (userRoutine))
  248. #define NewADSPCompletionProc(userRoutine)        \
  249.         ((ADSPCompletionUPP) (userRoutine))
  250. #endif
  251.  
  252. #if GENERATINGCFM
  253. #define CallADSPConnectionEventProc(userRoutine, sourceCCB)        \
  254.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppADSPConnectionEventProcInfo, (sourceCCB))
  255. #define CallADSPCompletionProc(userRoutine, thePBPtr)        \
  256.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppADSPCompletionProcInfo, (thePBPtr))
  257. #else
  258. /* (*ADSPConnectionEventProcPtr) cannot be called from a high-level language without the Mixed Mode Manager */
  259. /* (*ADSPCompletionProcPtr) cannot be called from a high-level language without the Mixed Mode Manager */
  260. #endif
  261.  
  262.  
  263. #ifdef __CFM68K__
  264. #pragma lib_export off
  265. #endif
  266.  
  267. #if GENERATINGPOWERPC
  268. #pragma options align=reset
  269. #endif
  270.  
  271. #ifdef __cplusplus
  272. }
  273. #endif
  274.  
  275. #endif /* __ADSP__ */
  276.